package com.limingru.newbee.api;

import com.limingru.newbee.api.vo.CategoryFirstLevelVO;
import com.limingru.newbee.service.CategoryService;
import com.limingru.newbee.util.Result;
import com.limingru.newbee.util.ResultGenerator;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/v1")
public class CategoryApi {

    @Resource
    CategoryService categoryService;

    @GetMapping("/category/all")
    public Result<List<CategoryFirstLevelVO>> categories() {
        List<CategoryFirstLevelVO> categories = categoryService.getCategories();
        return ResultGenerator.generateSuccessResult(categories);
    }
}
